Skip to content

Conversation

@Debjyoti2004
Copy link

Adds unit tests to the subscriber/pkg/k8s package to cover core logic.

  • Tests the 'addCustomLabels' utility function.
  • Tests the 'applyRequest' function for both 'get' and 'create' operations using a fake dynamic client.

Resolves: #4914

Proposed changes

This PR adds unit tests to the subscriber/pkg/k8s package to satisfy issue #4914.

The new tests in operations_test.go cover:

  • The addCustomLabels utility function.
  • The applyRequest function for both "get" and "create" operations, using a fake.NewSimpleDynamicClient to mock the Kubernetes API interaction.

Types of changes

What types of changes does your code introduce to Litmus? Put an x in the boxes that apply

  • New feature (non-breaking change which adds functionality)
  • Bugfix (non-breaking change which fixes an issue)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update (if none of the other choices applies)

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

  • I have read the CONTRIBUTING doc
  • I have signed the commit for DCO to be passed.
  • Lint and unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works (if appropriate)
  • I have added necessary documentation (if appropriate)

Dependency

  • None.

Special notes for your reviewer:

None.

Adds unit tests to the subscriber/pkg/k8s package to cover core logic.

- Tests the 'addCustomLabels' utility function.
- Tests the 'applyRequest' function for both 'get' and 'create' operations using a fake dynamic client.

Resolves: litmuschaos#4914
Signed-off-by: Debjyoti Shit <[email protected]>
@Debjyoti2004
Copy link
Author

Hi @PriteshKiri , it’s been over a week. Can someone review this PR? Thank you!

@SarthakJain26
Copy link
Contributor

@Debjyoti2004 can you please attach the screenshot of output you get after running these tests

@Debjyoti2004
Copy link
Author

Hi @SarthakJain26, here is the screenshot of the test output after running
go test -v inside chaoscenter/subscriber/pkg/k8s.

All tests are passing successfully.

Screenshot 2025-12-03 at 11 51 01 PM

Please let me know if you'd like me to run the full module tests as well.

@Debjyoti2004
Copy link
Author

Hi @SarthakJain26, I noticed that the docker-build-subscriber (pull_request) job is failing.

Looking at the logs, Trivy is reporting 1 HIGH vulnerability in the base image:

  • Image: docker.io/litmuschaos/litmusportal-subscriber:...
  • Package: sqlite-libs
  • CVE: CVE-2025-6965
  • Installed: 3.34.1-8.el9_6
  • Fixed version: 3.34.1-9.el9_7

This PR only adds unit tests under chaoscenter/subscriber/pkg/k8s (no changes to the Dockerfile or runtime dependencies), so I believe this failure is unrelated to my code changes.

Could you please advise how you’d like to handle this Trivy finding (e.g. updating the base image or adjusting the CI gate)? I’m happy to rebase or update the branch if needed once the image side is addressed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: add k8s subscriber unit test

3 participants